package com.xin.data.simbapesa.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaQuestiontypeItemBinding;
import com.xin.data.simbapesa.utils.ViewUtils;

import java.util.List;

public class QuestionTypeAdapter extends BaseBindingAdapter1<String, SimbaQuestiontypeItemBinding> {


    int index;

    public QuestionTypeAdapter(List<String> dataList) {
        super(dataList);
    }

    @Override
    protected void bindData(SimbaQuestiontypeItemBinding binding, String item, int position) {

        binding.tvTitle.setText(item);

        binding.tvTitle.setSelected(index == position);

        binding.tvTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                index = position;
                updateAllData();
            }
        });

    }

    @Override
    protected int getItemType(String item) {
        return 0;
    }

    @Override
    protected SimbaQuestiontypeItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaQuestiontypeItemBinding.inflate(inflater);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
